<?php
// +----------------------------------------------------------------------
// | 中犇单商户
// +----------------------------------------------------------------------
// | Copyright (c) 2019-2021 中犇科技 All rights reserved.
// +----------------------------------------------------------------------

namespace app\user\export;

use app\common\traits\controller\Export;
use app\user\model\User as UserModel;

/**
 * 会员主表控制器
 * @package app\User\admin
 */
class IndexExport
{
    use Export;
    /**
     * 会员主表列表
     * @author 似水星辰 [2630481389@qq.com]
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function export($map)
    {
        // 数据列表
        $list = UserModel::export($map);
        $_excelData = [];
        foreach ($list as &$item) {
            $item['sex'] = UserModel::$user_sex[$item['sex']];
        }
        unset($item);
        $_excelData[0]['list'] = $list;
        $xlsName = '会员信息-' . date("Y-m-d H:i:s", time());
        $xlsCell = [
            ['user_nickname', lang('昵称')],
            ['user_type', lang('会员类型')],
            ['sex', lang('性别')],
            ['mobile', lang('手机号')],
            ['user_money', lang('会员余额')],
            ['score', '会员积分	'],
            ['total_consumption_money', lang('累计消费金额')],
            ['count_score', lang('累计获取积分')],
            ['create_time', lang('注册时间')]
        ];
        $excelData = array_values($_excelData);
        $this->exportExcel($xlsName, $xlsCell, $excelData);
    }
}
